package com.madvirus.mediatest;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.MediaController;
import android.widget.VideoView;

public class MediaMainActivity extends Activity {

	private static String TAG = "MediaMainActivity";
	// private MediaController mediaController;
	private VideoView videoView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.i(TAG, "onCreate");
		setContentView(R.layout.main);

		playVideo();
	}

	private void playVideo() {
		videoView = (VideoView) findViewById(R.id.videoview);
		videoView
				.setVideoURI(Uri
						.parse("rtsp://wowza.racon.scgs.co.kr:1935/vod/_definst_/mp4:0000/00/2/2_PC1.mp4"));

		videoView.requestFocus();
		videoView.setOnPreparedListener(new OnPreparedListener() {

			@Override
			public void onPrepared(MediaPlayer mp) {
				videoView.start();
			}
		});
	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		videoView.stopPlayback();
	}

}
